import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/pages/Login.vue'
import Index from '@/pages/Index.vue'
import Home from '@/pages/Home.vue'
import Pay from '@/pages/admin/pay/Pay';
import PayInit from '@/pages/admin/pay/PayInit.vue';
import PaySuccess from '@/pages/admin/pay/PaySuccess.vue';

Vue.use(Router)

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    {
      path: '/login',
      name: '登陆页面',
      component: Login,
    },
    ,{
      path: '/paySuccess',
      name: '支付成功',
      component: PaySuccess,
    },
    {
      path: '/',
      component: Home,
      redirect: "admin/index",
      children: [
        {
          path: 'admin/index',
          name: '首页',
          component: Index,
        },
        {
          path: 'admin/pay/index',
          name: '支付页面',
          component: PayInit,
        }
        ,{
          path: 'admin/pay/doPay',
          name: '支付',
          component: Pay,
        }
      ]
    },
  ]
})
